﻿'use strict';

QuotingToolApp
//Search Customer
    .directive("quotesearchaccount", ['CommonServices', function (CommonServices) {
        return {
            restrict: "E",
            scope: {
                selectedAccount: "=ngModel"
            },
            link: function ($scope, element, attrs) {
                var self = this;
                $scope.getAccounts = function ($viewValue) {
                    if ($viewValue) {
                        return CommonServices.getAccounts($viewValue)
                            .$promise
                            .then(function (results) {                                
                                return results;

                            })
                            .catch(function (response) {
                                console.log(response);
                            }
                        );
                    }
                    else {
                        return null;
                    }
                }
            },
            templateUrl: 'Templates/SearchAccount.html'
        }
    }]);